package JVM;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicTest {

    private static AtomicInteger ato_i=new AtomicInteger(0);

    public static void main(String[] args) throws InterruptedException {

        Thread t1=new Thread(()->{
            for (int i=1;i<=10000;i++){
                ato_i.incrementAndGet();
            }
        });

        Thread t2=new Thread(()->{
            for (int i=1;i<=10000;i++){
                ato_i.incrementAndGet();
            }
        });
        t1.start();
        t2.start();
        //我真是太聪明了 哈哈哈 虽然这个join操作很基本，但是因为我多线程没有动手写过什么，这次还知道加join，哈哈哈哈，我厉害
        t1.join();
        t2.join();
        System.out.println(ato_i.get());
    }
}
